import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { JVxeTypes, JVxeColumn } from '/@/components/jeecg/JVxeTable/types'
import type { Rule } from 'ant-design-vue/es/form';
//列表数据
export const columns: BasicColumn[] = [

  {
    title: '编码',
    align: "center",
    sorter: true,
    dataIndex: 'workCalendarCoding',
  },
  {
    title: '名称',
    align: "center",
    sorter: true,
    dataIndex: 'workCalendarName'
  },
  {
    title: '开始日期',
    align: "center",
    sorter: true,
    dataIndex: 'startTime',
    customRender: ({ text }) => {
      return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
    },
  },
  {
    title: '结束日期',
    align: "center",
    sorter: true,
    dataIndex: 'endTime',
    customRender: ({ text }) => {
      return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
    },
  },
  {
    title: '是否已生成',
    align: "center",
    dataIndex: 'isGenerate',
    customRender: ({ text }) => {
      return text == 1 ? '是' : '否'
    },
  },
  {
    title: '第三方编码',
    align: "center",
    dataIndex: 'thirdPartyCode',
    ifShow: false
  },
  {
    title: '描述',
    align: "center",
    dataIndex: 'remark'
  },
];
export const BusCancelWorkOrderData: FormSchema[] = [
  {
    label: '追加结束时间',
    field: 'endTime',
    component: 'DatePicker',
    colProps: {
      span: 12
    },
    dynamicDisabled: true
  },
  {
    label: '结束时间',
    field: 'appendEndDate',
    component: 'DatePicker',
    colProps: {
      span: 12
    },
    componentProps: {
      // picker: 'year',
      showTime: false,
      valueFormat: 'YYYY-MM-DD'
  },
  }
]

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "编码",
    field: "workCalendarCoding",
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: "名称",
    field: "workCalendarName",
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: "开始日期",
    field: "startTime",
    component: 'DatePicker',
    colProps: { span: 6 },
  },
  {
    label: "结束日期",
    field: "endTime",
    component: 'DatePicker',
    colProps: { span: 6 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [

  {
    label: '编码',
    field: 'workCalendarCoding',
    component: 'Input',
    rules: [
      {
        required: true,
        message: '编码必填',
        trigger: 'blur',
      },
    ]
  },
  {
    label: '名称',
    field: 'workCalendarName',
    component: 'Input',
    rules: [
      {
        required: true,
        message: '名称必填',
        trigger: 'blur',
      },
    ]
  },
  {
    label: '开始日期',
    field: 'startTime',
    component: 'DatePicker',
    rules: [
      {
        required: true,
        message: '开始日期必填',
        trigger: 'blur',
      },
    ]
  },
  {
    label: '结束日期',
    field: 'endTime',
    component: 'DatePicker',
    componentProps: {
      getPopupContainer: () => document.body,
    },
    rules: [
      {
        required: true,
        message: '结束日期必填',
        trigger: 'blur',
        // validator: async (_rule: Rule, value: string | number) => {
        //   console.log('endTIme...', value)
        // }
      },
    ]
  },
  {
    label: '描述',
    field: 'remark',
    component: 'InputTextArea',
    colProps: {
      span: 16
    }
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];
//子表单数据
//子表表格配置
export const psWorkingCalendarRuleColumns: JVxeColumn[] = [
  {
    title: '工作日历id',
    key: 'workingCalendarId',
    type: JVxeTypes.hidden,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '类型',
    key: 'type',
    type: JVxeTypes.select,
    width: "100px",
    placeholder: '请输入${title}',
    options:[{value:1,label:'固定日期'},{value:2,label:'周'}],
    defaultValue: 1,
  },
  {
    title: '是否工作日',
    key: 'isWorkingDay',
    type: JVxeTypes.select,
    width: "120px",
    placeholder: '请输入${title}',
    options:[{value:1,label:'是'},{value:0,label:'否'}],
    defaultValue: 1,
  },
  {
    title: '日期',
    key: 'date',
    type: JVxeTypes.date,
    width: "120px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '月',
    key: 'month',
    type: JVxeTypes.input,
    width: "100px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '周',
    key: 'week',
    type: JVxeTypes.select,
    width: "100px",
    placeholder: '请输入${title}',
    options:[{value:1,label:'周一'},{value:2,label:'周二'},{value:3,label:'周三'},{value:4,label:'周四'},{value:5,label:'周五'},{value:6,label:'周六'},{value:7,label:'周日'}],
    defaultValue: '',
  },
  {
    title: '规则优先顺序',
    key: 'rulePrecedence',
    type: JVxeTypes.inputNumber,
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  // {
  //   title: '日期类型',
  //   key: 'dateType',
  //   type: JVxeTypes.select,
  //   width: "200px",
  //   options:[{value:1,label:'休息日'},{value:2,label:'工作日'}],
  //   placeholder: '请选择${title}',
  //   defaultValue: 1,
  // },
  // {
  //   title: '删除状态 0正常 1已删除',
  //   key: 'delFlag',
  //   type: JVxeTypes.input,
  //   width: "200px",
  //   placeholder: '请输入${title}',
  //   defaultValue: '',
  // },
]
export const psWorkingCalendarClassesRuleColumns: JVxeColumn[] = [
  // {
  //   title: '租户id',
  //   key: 'tenantId',
  //   type: JVxeTypes.input,
  //   width: "200px",
  //   placeholder: '请输入${title}',
  //   defaultValue: '',
  // },
  // {
  //   title: '组织id',
  //   key: 'organizationId',
  //   type: JVxeTypes.input,
  //   width: "200px",
  //   placeholder: '请输入${title}',
  //   defaultValue: '',
  // },
  // {
  //   title: '组织名称',
  //   key: 'organizationName',
  //   type: JVxeTypes.input,
  //   width: "200px",
  //   placeholder: '请输入${title}',
  //   defaultValue: '',
  // },
  // {
  //   title: '工作日历id',
  //   key: 'workingCalendarId',
  //   type: JVxeTypes.input,
  //   width: "200px",
  //   placeholder: '请输入${title}',
  //   defaultValue: '',
  // },
  {
    title: '班次id',
    key: 'workCalendarId',
    type: JVxeTypes.hidden,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '班次',
    key: 'workCalendarName',
    type: JVxeTypes.slot,
    placeholder: '请输入${title}',
    defaultValue: '',
    slotName:'workCalendarSlot'
  },
  {
    title: '班次类别',
    key: 'classShift',
    type: JVxeTypes.select,
    options:[{value:1,label:'白班'},{value:2,label:'夜班'}],
    placeholder: '请选择${title}',
    defaultValue: '',
  },
  {
    title: '产能策略',
    key: 'type',
    type: JVxeTypes.select,
    options:[{value:1,label:'固定日期'},{value:2,label:'周'}],
    placeholder: '请选择${title}',
    defaultValue: '',
  },
]
export const psWorkingCalendarParticularsColumns: JVxeColumn[] = [

  {
    title: '工作日历id',
    key: 'workingCalendarId',
    type: JVxeTypes.hidden,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '工作日编号',
    key: 'workingNumber',
    type: JVxeTypes.normal,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '日期',
    key: 'workCalendarDetailsDate',
    type: JVxeTypes.normal,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '星期名称',
    key: 'nameweek',
    type: JVxeTypes.normal,
    width: "200px",
    placeholder: '请输入${title}',
    options:[{value:1,label:'周一'},{value:2,label:'周二'},{value:3,label:'周三'},{value:4,label:'周四'},{value:5,label:'周五'},{value:6,label:'周六'},{value:7,label:'周日'}],
    defaultValue: 1,
  },
  {
    title: '是否工作日',
    key: 'workingdaynot',
    type: JVxeTypes.select,
    width: "200px",
    placeholder: '请输入${title}',
    options:[{value:1,label:'是'},{value:0,label:'否'}],
    defaultValue: 1,
  },
  // {
  //   title: '日期类型',
  //   key: 'datetype',
  //   type: JVxeTypes.select,
  //   width: "200px",
  //   options:[{value:1,label:'工作日'},{value:2,label:'休息日'}],
  //   placeholder: '请输入${title}',
  //   defaultValue:1,
  // },
  {
    title: '月份',
    key: 'month',
    type: JVxeTypes.normal,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
]


/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}

